<template>
  <div>
    <el-row :gutter="15">
      <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
        <el-col :span="12">
          <el-form-item label="学号" prop="id">
            <el-input v-model="formData.id" placeholder="请输入学号" clearable :style="{width: '100%'}"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="姓名" prop="Name">
            <el-input v-model="formData.Name" placeholder="请输入姓名" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="性别" prop="Sex">
            <el-input v-model="formData.Sex" placeholder="请输入性别" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="系别" prop="Department">
            <el-input v-model="formData.Department" placeholder="请输入系别" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="年龄" prop="Age">
            <el-input v-model="formData.Age" placeholder="请输入年龄" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="身高" prop="Height">
            <el-input v-model="formData.Height" placeholder="请输入身高" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="体重" prop="Weight">
            <el-input v-model="formData.Weight" placeholder="请输入体重" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="胸围" prop="Bust">
            <el-input v-model="formData.Bust" placeholder="请输入胸围" clearable :style="{width: '100%'}">
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="日期选择" prop="Date">
            <el-date-picker v-model="formData.Date" format="yyyy-MM-dd" value-format="yyyy-MM-dd"
                            :style="{width: '100%'}" placeholder="请选择日期" clearable></el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item size="large">
            <el-button type="primary" @click="submitForm">提交</el-button>
            <el-button @click="resetForm">重置</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>
  </div>
</template>
<script>
import axios from "axios";
import qs from "qs";


export default {
  components: {},
  props: [],
  data() {
    return {
      formData: {
        id: undefined,
        Name: undefined,
        Sex: undefined,
        Department: undefined,
        Age: undefined,
        Height: undefined,
        Weight: undefined,
        Bust: undefined,
        Date: null,
      },
      rules: {
        id: [{
          required: true,
          message: '请输入学号',
          trigger: 'blur'
        }],
        Name: [{
          required: true,
          message: '请输入姓名',
          trigger: 'blur'
        }],
        Sex: [{
          required: true,
          message: '请输入性别',
          trigger: 'blur'
        }],
        Department: [{
          required: true,
          message: '请输入系别',
          trigger: 'blur'
        }],
        Age: [],
        Height: [],
        Weight: [],
        Bust: [],
        Date: [{
          required: true,
          message: '请选择日期',
          trigger: 'blur'
        }],
      },
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    submitForm() {
      let da = this.formData;
      alert(qs.stringify(da));
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        // TODO 提交表单
        axios.post('http://localhost:8080/medicaldocuments/Add', qs.stringify(da))
      })
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
  }
}

</script>
<style>
</style>
